import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: (resolve) => require(['@/views/redirect'], resolve)
      }
    ]
  },
  // 可视化大屏，单页面新窗口打开
  // {
  //   path: '/screen',
  //   hidden: true,
  //   children: [
  //     {
  //       path: '/screen1',
  //       component: (resolve) => require(['@/views/screen/screen1/index'], resolve)
  //     }
  //   ]
  // },
  // {
  //   path: '/screen/screen1',
  //   component: (resolve) => require(['@/views/screen/screen1/index'], resolve),
  //   hidden: true
  // },
  {
    path: '/screen/screen1',
    component: (resolve) => require(['@/views/screen/screen1/index'], resolve),
    hidden: true
  },
  {
    path: '/screen/screen2',
    component: (resolve) => require(['@/views/screen/screen2/index'], resolve),
    hidden: true
  },
  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/register',
    component: (resolve) => require(['@/views/register'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '/report/view/:reportId(\\d+)',
    component: (resolve) => require(['@/views/engineering/report/view'], resolve),
    hidden: true
  },
  {
    path: '/report/projectView/:reportId(\\d+)',
    component: (resolve) => require(['@/views/engineering/report/projectView'], resolve),
    hidden: true
  },
  {
    path: '/sup/report/view/:reportId(\\d+)',
    component: (resolve) => require(['@/views/supervisor/report/view'], resolve),
    hidden: true
  },
  {
    path: '/agency/report/view/:reportId(\\d+)',
    component: (resolve) => require(['@/views/agency/report/view'], resolve),
    hidden: true
  },
  {
    path: '/labour/report/staff/:reportId(\\d+)',
    component: (resolve) => require(['@/views/site/labour/report/staff'], resolve),
    hidden: true
  },
  {
    path: '/labour/report/salary/:reportId(\\d+)',
    component: (resolve) => require(['@/views/site/labour/report/salary'], resolve),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/index'], resolve),
        name: 'Index',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'profile',
        component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
        name: 'Profile',
        meta: { title: '个人中心', icon: 'user' }
      }
    ]
  },
  {
    path: '/system/user-auth',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'role/:userId(\\d+)',
        component: (resolve) => require(['@/views/system/user/authRole'], resolve),
        name: 'AuthRole',
        meta: { title: '分配角色', activeMenu: '/system/user'}
      }
    ]
  },
  {
    path: '/system/user-auth',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'report/:userId(\\d+)',
        component: (resolve) => require(['@/views/system/user/authReport'], resolve),
        name: 'AuthUserReport',
        meta: { title: '用户分配报表', activeMenu: '/system/user'}
      }
    ]
  },
  {
    path: '/system/role-auth',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'user/:roleId(\\d+)',
        component: (resolve) => require(['@/views/system/role/authUser'], resolve),
        name: 'AuthUser',
        meta: { title: '分配用户', activeMenu: '/system/role'}
      }
    ]
  },
  {
    path: '/system/role-auth',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'report/:roleId(\\d+)',
        component: (resolve) => require(['@/views/system/role/authReport'], resolve),
        name: 'AuthRoleReport',
        meta: { title: '角色分配报表', activeMenu: '/system/role'}
      }
    ]
  },
  {
    path: '/system/dict-data',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index/:dictId(\\d+)',
        component: (resolve) => require(['@/views/system/dict/data'], resolve),
        name: 'Data',
        meta: { title: '字典数据', activeMenu: '/system/dict'}
      }
    ]
  },
  {
    path: "/project/meterage",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'meterage',
        component: (resolve) => require(['@/views/project/boq/meterage'], resolve),
        name: 'Meterage',
        meta: { title: '计量清单', activeMenu: '/project/boq'}
      }
    ]
  },
  {
    path: "/engineering/change/detail",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index/:changeId(\\d+)',
        component: (resolve) => require(['@/views/engineering/change/detail'], resolve),
        name: 'ChangeDetail',
        meta: { title: '变更令详情', activeMenu: '/engineering/change'}
      }
    ]
  },
  {
    path: "/engineering/meterage/detail",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index/:masterId(\\d+)',
        component: (resolve) => require(['@/views/engineering/meterage/detail'], resolve),
        name: 'MeterageDetail',
        meta: { title: '工程计量详情', activeMenu: '/engineering/meterage'}
      }
    ]
  },
  {
    path: "/project/payment",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index/:projectId(\\d+)',
        component: (resolve) => require(['@/views/project/payment/index'], resolve),
        name: 'PaymentItem',
        meta: { title: '工程支付项目', activeMenu: '/project/project'}
      }
    ]
  },
  {
    path: "/project/report",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index/:projectId(\\d+)',
        component: (resolve) => require(['@/views/project/report/index'], resolve),
        name: 'Report',
        meta: { title: '工程项目报表', activeMenu: '/project/project'}
      }
    ]
  },
  {
    path: "/project/supervisor",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'boq/:projectId(\\d+)',
        component: (resolve) => require(['@/views/project/supervisor/boq'], resolve),
        name: 'ProjectSupervisorBoq',
        meta: { title: '项目监理清单', activeMenu: '/project/project'}
      },
      {
        path: 'items/:projectId(\\d+)',
        component: (resolve) => require(['@/views/project/supervisor/items'], resolve),
        name: 'ProjectSupervisorItems',
        meta: { title: '监理支付项目', activeMenu: '/project/project'}
      }
    ]
  },
  {
    path: "/project/agency",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'boq/:projectId(\\d+)',
        component: (resolve) => require(['@/views/project/agency/boq'], resolve),
        name: 'ProjectAgencyBoq',
        meta: { title: '项目代建清单', activeMenu: '/project/project'}
      },
      {
        path: 'items/:projectId(\\d+)',
        component: (resolve) => require(['@/views/project/agency/items'], resolve),
        name: 'ProjectAgencyItems',
        meta: { title: '代建支付项目', activeMenu: '/project/project'}
      }
    ]
  },
  {
    path: "/project/profile",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'boq/:projectId(\\d+)',
        component: (resolve) => require(['@/views/project/profile/boq'], resolve),
        name: 'ProjectProfileBoq',
        meta: { title: '项目形象清单', activeMenu: '/project/project'}
      }
    ]
  },
  {
    path: "/supervisor/meterage/detail",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index/:masterId(\\d+)',
        component: (resolve) => require(['@/views/supervisor/meterage/detail'], resolve),
        name: 'SupervisorMeterageDetail',
        meta: { title: '监理计量详情', activeMenu: '/supervisor/meterage'}
      }
    ]
  },
  {
    path: "/agency/meterage/detail",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index/:masterId(\\d+)',
        component: (resolve) => require(['@/views/agency/meterage/detail'], resolve),
        name: 'AgencyMeterageDetail',
        meta: { title: '代建计量详情', activeMenu: '/agency/meterage'}
      }
    ]
  },
  {
    path: "/workflow/meterage/node",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/workflow/meterage/node'], resolve),
        name: 'MeterageNode',
        meta: { title: '计量流程节点', activeMenu: '/workflow/meterage'}
      }
    ]
  },
  {
    path: "/site/labour/staff",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'view/:id(\\d+)',
        component: (resolve) => require(['@/views/site/labour/staff/view'], resolve),
        name: 'staffView',
        meta: { title: '人员信息卡', activeMenu: '/site/labour/staff/index'}
      }
    ]
  },
  {
    path: "/plan/profile",
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'overall/detail/:masterId(\\d+)',
        component: (resolve) => require(['@/views/plan/profile/overall/detail'], resolve),
        name: 'ProfileOverallDetail',
        meta: { title: '总体形象计划详情', activeMenu: '/plan/profile/overall'}
      },
      {
        path: 'year/detail/:masterId(\\d+)',
        component: (resolve) => require(['@/views/plan/profile/year/detail'], resolve),
        name: 'ProfileYearDetail',
        meta: { title: '年形象计划详情', activeMenu: '/plan/profile/year'}
      },
      {
        path: 'month/detail/:masterId(\\d+)',
        component: (resolve) => require(['@/views/plan/profile/month/detail'], resolve),
        name: 'ProfileMonthDetail',
        meta: { title: '月形象计划详情', activeMenu: '/plan/profile/month'}
      },
      {
        path: 'schedule/detail/:masterId(\\d+)',
        component: (resolve) => require(['@/views/plan/profile/schedule/detail'], resolve),
        name: 'ProfileScheduleDetail',
        meta: { title: '形象进度详情', activeMenu: '/plan/profile/schedule'}
      }
    ]
  },
  {
    path: '/monitor/job-log',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/monitor/job/log'], resolve),
        name: 'JobLog',
        meta: { title: '调度日志', activeMenu: '/monitor/job'}
      }
    ]
  },
  {
    path: '/tools/gen-edit',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/tools/gen/editTable'], resolve),
        name: 'GenEdit',
        meta: { title: '修改生成配置', activeMenu: '/tools/gen'}
      }
    ]
  },
]

export default new Router({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
